define(function(require,exports,module){
    var Base={
		mBaserSvrUrl:window.BaseServerUrl,
		localStorage:window.localStorage
	};
	
	function JlnRequest(){
		this.params={}
	}
	module.exports=PublicNotifyProxy;
function PublicNotifyProxy(){
	function publicnotifySubmit(request, success, ignoreError) {
	    var url = Base.mBaserSvrUrl+'/publicnotify';
        if (request.svr == null) request.svr = undefined;
	    if (request.token == null) request.token = undefined;
	    var content = JSON.stringify(request);
       
	    url = url + '?f=t&data=' + encodeURIComponent(content);
	    url = url + '&CallBack=?';
        $.getJSON(url,success);

	}

	function ICBCPayNotifyRq(union,merVAR,notifyData,signMsg,success,ignoreError){
        var request=new JlnRequest();
        request.func='ICBCPayNotify';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['mvar']=merVAR;
		request.params['nd']=notifyData;
		request.params['sm']=signMsg;

		if (union == true) {
	        request.svr = 'publicnotify';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.ICBCPayNotifyRequest=function(merVAR,notifyData,signMsg,success,ignoreError){
       var request= ICBCPayNotifyRq(true,merVAR,notifyData,signMsg,success,ignoreError);
       return request;
    }
	this.ICBCPayNotify=function(merVAR,notifyData,signMsg,success,ignoreError){
       var request= ICBCPayNotifyRq(false,merVAR,notifyData,signMsg,success,ignoreError);
       publicnotifySubmit(request, success, ignoreError);

    }

	function TLTPayNotifyRq(union,merchantId,version,language,signType,payType,issuerId,paymentOrderId,orderNo,orderDatetime,orderAmount,payDatetime,payAmount,ext1,ext2,payResult,errorCode,returnDatetime,signMsg,success,ignoreError){
        var request=new JlnRequest();
        request.func='TLTPayNotify';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['mid']=merchantId;
		request.params['v']=version;
		request.params['l']=language;
		request.params['st']=signType;
		request.params['pt']=payType;
		request.params['iid']=issuerId;
		request.params['poid']=paymentOrderId;
		request.params['on']=orderNo;
		request.params['od']=orderDatetime;
		request.params['oa']=orderAmount;
		request.params['pd']=payDatetime;
		request.params['pa']=payAmount;
		request.params['e']=ext1;
		request.params['e0']=ext2;
		request.params['pr']=payResult;
		request.params['ec']=errorCode;
		request.params['rd']=returnDatetime;
		request.params['sm']=signMsg;

		if (union == true) {
	        request.svr = 'publicnotify';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.TLTPayNotifyRequest=function(merchantId,version,language,signType,payType,issuerId,paymentOrderId,orderNo,orderDatetime,orderAmount,payDatetime,payAmount,ext1,ext2,payResult,errorCode,returnDatetime,signMsg,success,ignoreError){
       var request= TLTPayNotifyRq(true,merchantId,version,language,signType,payType,issuerId,paymentOrderId,orderNo,orderDatetime,orderAmount,payDatetime,payAmount,ext1,ext2,payResult,errorCode,returnDatetime,signMsg,success,ignoreError);
       return request;
    }
	this.TLTPayNotify=function(merchantId,version,language,signType,payType,issuerId,paymentOrderId,orderNo,orderDatetime,orderAmount,payDatetime,payAmount,ext1,ext2,payResult,errorCode,returnDatetime,signMsg,success,ignoreError){
       var request= TLTPayNotifyRq(false,merchantId,version,language,signType,payType,issuerId,paymentOrderId,orderNo,orderDatetime,orderAmount,payDatetime,payAmount,ext1,ext2,payResult,errorCode,returnDatetime,signMsg,success,ignoreError);
       publicnotifySubmit(request, success, ignoreError);

    }

	function postJournalismRq(union,title,url,pictureUrl,author,interviewPersons,interviewTime,desc,priority,type,sign,success,ignoreError){
        var request=new JlnRequest();
        request.func='postJournalism';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['t']=title;
		request.params['u']=url;
		request.params['pu']=pictureUrl;
		request.params['a']=author;
		request.params['ip']=interviewPersons;
		request.params['it']=interviewTime;
		request.params['d']=desc;
		request.params['p']=priority;
		request.params['t0']=type;
		request.params['s']=sign;

		if (union == true) {
	        request.svr = 'publicnotify';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.postJournalismRequest=function(title,url,pictureUrl,author,interviewPersons,interviewTime,desc,priority,type,sign,success,ignoreError){
       var request= postJournalismRq(true,title,url,pictureUrl,author,interviewPersons,interviewTime,desc,priority,type,sign,success,ignoreError);
       return request;
    }
	this.postJournalism=function(title,url,pictureUrl,author,interviewPersons,interviewTime,desc,priority,type,sign,success,ignoreError){
       var request= postJournalismRq(false,title,url,pictureUrl,author,interviewPersons,interviewTime,desc,priority,type,sign,success,ignoreError);
       publicnotifySubmit(request, success, ignoreError);

    }
}

});
